<template>
	<view class="container">
		<block v-if="isload">
			<dd-tab :itemdata="['全部', '待付款', '待发货', '待收货', '已完成']" :itemst="['all', '0', '1', '2', '3']" :st="st"
				:isfixed="true" @changetab="changetab"></dd-tab>
			<view style="width:100%;height:100rpx"></view>
			<!-- #ifndef H5 || APP-PLUS -->
			<view class="topsearch flex-y-center">
				<view class="f1 flex-y-center">
					<image class="img" src="/static/img/search_ico.png"></image>
					<input :value="keyword" placeholder="输入关键字搜索" placeholder-style="font-size:24rpx;color:#C2C2C2"
						@confirm="searchConfirm"></input>
				</view>
			</view>
			<!--  #endif -->
			<view class="order-content">
				<block v-for="(item, index) in datalist" :key="index">
					<!-- <view class="order-box" @tap="goto" :data-url="'detail?id=' + item.id"> -->
					<view class="order-box" @click="goDetail(item, item.id)">
						<view class="head">
							<view class="f1" v-if="item.bid != 0" @tap.stop="goto"
								:data-url="'/pagesExt/business/index?id=' + item.bid">
								<image src="/static/img/ico-shop.png"></image> {{ item.binfo.name }}
							</view>
							<view class="f1" v-else>
								<image :src="item.binfo.logo" class="logo-row"></image> {{ item.binfo.name }}
							</view>
							<view class="flex1">
								<text style="color:orangered; margin-left: 10rpx;"
									v-if="item.yuding_type && item.yuding_type == '1'">[预定订单]</text>
							</view>
							<text v-if="item.status == 0" class="st0">待付款</text>
							<text v-if="item.status == 1 && item.freight_type != 1" class="st1">待发货</text>
							<text v-if="item.status == 1 && item.freight_type == 1" class="st1">待提货</text>
							<text v-if="item.status == 2" class="st2">待收货</text>
							<text v-if="item.status == 3" class="st3">已完成</text>
							<text v-if="item.status == 4" class="st4">已关闭</text>
						</view>

						<block v-for="(item2, idx) in item.prolist" :key="idx">
							<view class="bottom" v-if="item.tips != '' && item.order_type != 2">
								<block v-if="item.express_comArr">
									<block v-for="(item3, idx1) in item.express_comArr" :key="idx1">
										<block v-if="item3.express_ogid == item2.id">
											<view class="tips-box">
												<view class="tips-box-left">
													<view class="tips-text">
														{{ item3.tips }}
													</view>
													<view class="tips-time">
														{{ item3.tips_time }}
													</view>
												</view>
												<view class="tips-box-right">
													<image class="arrow-right" src="/static/img/arrowright.png" mode="">
													</image>
												</view>
											</view>
										</block>
									</block>
								</block>
								<block v-else-if="idx == 0">
									<view class="tips-box">
										<view class="tips-box-left">
											<view class="tips-text">
												{{ item.tips }}
											</view>
											<view class="tips-time">
												{{ item.tips_time }}
											</view>
										</view>
										<view class="tips-box-right">
											<image class="arrow-right" src="/static/img/arrowright.png" mode=""></image>
										</view>
									</view>
								</block>
							</view>
							<view class="content" :style="idx + 1 == item.procount ? 'border-bottom:none' : ''">
								<!-- <view @tap.stop="goto" 
									:data-url="'/pages/shop/product?id=' + item2.proid">
									<image :src="item2.pic"></image> -->
								<view @tap.stop="gotoproid(item2, item.from_order_type)">
									<image :src="item2.pic"></image>
								</view>
								<view class="detail">
									<text class="t1">{{ item2.name }}</text>
									<text class="t2">{{ item2.ggname }}</text>
									<view class="t3">
										<text class="x1 flex1"><text v-if="showprice_dollar && item2.usd_sellprice">${{
											item2.usd_sellprice }}
											</text>￥{{ item2.sell_price }}</text>
										<text class="x2">×{{ item2.num }}</text>
									</view>
									<view class="t2 tgr" v-if="item2.isrefund == 1">
										注：商品不允许退款
									</view>
									<view class="t2 tgr" v-if="item2.has_glassrecord">
										{{ item2.glassrecord.name }}
										{{ item2.glassrecord.nickname ? item2.glassrecord.nickname : '' }}
										{{ item2.glassrecord.check_time ? item2.glassrecord.check_time : '' }}
										{{ item2.glassrecord.typetxt }}
										<!-- <block>
										<text class="pdl10" v-if="item2.glassrecord.double_ipd==0">{{item2.glassrecord.ipd?'PD'+item2.glassrecord.ipd:''}}</text>
										<text class="pdl10" v-else> PD R{{item2.glassrecord.ipd_right}} L{{item2.glassrecord.ipd_left}}</text>
									</block> -->
									</view>

									<block v-if="(item.status == 1 || item.status == 2) && item2.hexiao_code">
										<view class="btn2" @tap.stop="showhxqr2" :data-id="item2.id"
											:data-num="item2.num" :data-hxnum="item2.hexiao_num"
											:data-hexiao_code="item2.hexiao_code"
											style="position:absolute;top:40rpx;right:0rpx;">核销码</view>
									</block>
								</view>
							</view>
						</block>
						<view class="bottom2">
							<view class="ordertype" :style="{ color: t('color1') }">{{
								getOrderType(item.from_order_type, item.order_type) }}</view>
							<text>共计{{ item.procount }}件商品 实付:￥{{ item.totalprice }} <text
									v-if="item.balance_price > 0 && item.balance_pay_status == 0"
									style="display: block; float: right;">尾款：￥{{ item.balance_price }}</text></text>
							<text v-if="item.refund_status == 1" style="color:red;padding-left:6rpx">退款中￥{{
								item.refund_money }}</text>
							<text v-if="item.refund_status == 2" style="color:red;padding-left:6rpx">已退款￥{{
								item.refund_money }}</text>
							<text v-if="item.refund_status == 3" style="color:red;padding-left:6rpx">退款申请已驳回</text>

						</view>

						<view class="bottom gift-box" v-if="item.order_type == 2">
							<view class="gift-left">
								<view class="gift-left-img">
									<image class="img-icon" src="/static/img/store.png" mode=""></image>
								</view>
								<view>{{ item.tips }}</view>
							</view>
							<view class="gift-right">
								<view class="">
									共
									<text>{{ item.gift_total_num }}</text>
									份礼包/
									<text>{{ item.gift_use_num }}</text>
									人已领
								</view>
							</view>
						</view>
						<view class="op">
							<view
								v-if="item.order_type == 2 && item.status == 1 && item.gift_total_num > item.gift_use_num"
								class="btn2">
								<button class="btn-share" open-type="share" @click.stop="handleShare(item)"
									ref="shareButton">分享礼包</button>
							</view>
							<block v-if="([1, 2, 3]).includes(item.status) && item.invoice">
								<view class="btn2" @tap.stop="goto" :data-url="'invoice?type=shop&orderid=' + item.id">
									发票</view>
							</block>
							<!-- <view v-if="item.status == 3" @tap.stop="goto" :data-url="'comment?ogid=' + item.id"
								class="btn2">去评价</view> -->
							<block v-if="item.status == 3">
								<view class="btn2" v-if="item.iscomment == 1" @tap.stop="goto"
									:data-url="'comment?ogid=' + item.id">
									查看评价
								</view>
								<view class="btn2" v-else @tap.stop="goto" :data-url="'comment?ogid=' + item.id">
									去评价
								</view>
							</block>

							<view @tap.stop="goto" :data-url="'detail?id=' + item.id" class="btn2">详情</view>
							<block v-if="item.status == 0">
								<view class="btn2" @tap.stop="toclose" :data-id="item.id">关闭订单</view>
								<view class="btn1" v-if="item.paytypeid != 5" :style="{ background: t('color1') }"
									@tap.stop="goto" :data-url="'/pages/pay/pay?id=' + item.payorderid">去付款</view>
								<block v-if="item.paytypeid == 5">
									<view class="btn1" v-if="item.transfer_check == 1"
										:style="{ background: t('color1') }" @tap.stop="goto"
										:data-url="'/pages/pay/transfer?id=' + item.payorderid">付款凭证
									</view>
									<view class="btn1" v-else :style="{ background: t('color1') }">
										<text v-if="item.transfer_check == 0">转账待审核</text>
										<text v-if="item.transfer_check == -1">转账已驳回</text>
									</view>
								</block>

							</block>
							<block v-if="item.status == 1">
								<block v-if="!is_product_glass && item.paytypeid != '4' && item.canrefund == 0">
									<view class="btn2" @tap.stop="goto"
										:data-url="'refundSelect?orderid=' + item.id + '&price=' + item.totalprice+'&refundType='+checkRT(item)"
										v-if="canrefund == 1 && item.refundnum < item.procount">退款</view>
								</block>
								<block v-else>
									<!-- <view class="btn2">{{codtxt}}</view> -->
								</block>
							</block>
							<block v-if="item.status == 2">
								<block v-if="!is_product_glass && item.paytypeid != '4' && item.canrefund == 0">
									<view class="btn2" @tap.stop="goto"
										:data-url="'refundSelect?orderid=' + item.id + '&price=' + item.totalprice"
										v-if="canrefund == 1 && item.refundnum < item.procount">退款</view>
								</block>
								<block v-else>
									<!-- <view class="btn2">{{codtxt}}</view> -->
								</block>
								<block v-if="item.freight_type != 3 && item.freight_type != 4">
									<view class="btn2" v-if="item.express_type == 'express_wx'" @tap.stop="logistics"
										:data-index="index">订单跟踪</view>
									<view class="btn2" v-else @tap.stop="logistics" :data-index="index">查看物流</view>
								</block>

								<view v-if="item.balance_pay_status == 0 && item.balance_price > 0" class="btn1"
									:style="{ background: t('color1') }" @tap.stop="goto"
									:data-url="'/pages/pay/pay?id=' + item.balance_pay_orderid">支付尾款</view>
								<view
									v-if="item.paytypeid != '4' && (item.balance_pay_status == 1 || item.balance_price == 0)"
									class="btn1" :style="{ background: t('color1') }" @tap.stop="orderCollect"
									:data-id="item.id">确认收货</view>
							</block>
							<block
								v-if="(item.status == 1 || item.status == 2) && item.freight_type == 1 && item.hexiao_qr">
								<view class="btn2" @tap.stop="showhxqr" :data-hexiao_qr="item.hexiao_qr">核销码</view>
							</block>
							<view v-if="item.refundCount" class="btn2" @tap.stop="goto"
								:data-url="'refundlist?orderid=' + item.id">查看退款</view>
							<block v-if="item.status == 3 || item.status == 4">
								<view class="btn2" @tap.stop="todel" :data-id="item.id">删除订单</view>
							</block>
							<block v-if="item.bid > 0 && item.status == 3 && 0">
								<view v-if="item.iscommentdp == 0" class="btn1" :style="{ background: t('color1') }"
									@tap.stop="goto" :data-url="'/pagesExt/order/commentdp?orderid=' + item.id">评价店铺
								</view>
							</block>
						</view>
					</view>
				</block>
			</view>
			<nomore v-if="nomore"></nomore>
			<nodata v-if="nodata"></nodata>
			<block v-if="datalist.length==0">
				<view class="waterfall-container">
					<view class="like">
						<image class="like-icon"
							src="https://hedashepin.oss-cn-guangzhou.aliyuncs.com/upload/3/20250407/1086317011f641d4dd9fc9a67b24ca9e.png"
							mode=""></image>
						<text>你可能还喜欢</text>
					</view>
					<view class="waterfall-list">
						<!-- 左侧列 -->
						<view class="waterfall-column">
							<view class="item" v-for="(item, index) in leftColumnList" :key="'left-' + index"
								:data-url="'/pages/shop/product?id=' + item.id" @click="goto">
								<image class="shop-image" :src="item.pic" mode="widthFix"></image>
								<view class="shop-text">
									<view class="shop-text-left">
										<view class="shop-text-name">{{ item.name }}</view>
										<view class="shop-text-price">
											<view>￥{{ item.sell_price }}</view>
											<view class="shop-text-sales">销量:{{ item.sales }}</view>
										</view>
									</view>
									<view>
										<image class="shop-add"
											src="https://hedashepin.oss-cn-guangzhou.aliyuncs.com/upload/3/20250402/09cf0a1a6c7c2efd061d325e7722f543.png"
											mode=""></image>
									</view>
								</view>
							</view>
						</view>

						<!-- 右侧列 -->
						<view class="waterfall-column">
							<view class="item" v-for="(item, index) in rightColumnList" :key="'right-' + index"
								:data-url="'/pages/shop/product?id=' + item.id" @click="goto">
								<image class="shop-image" :src="item.pic" mode="widthFix"></image>
								<view class="shop-text">
									<view class="shop-text-left">
										<view class="shop-text-name">{{ item.name }}</view>
										<view class="shop-text-price">
											<view>￥{{ item.sell_price }}</view>
											<view class="shop-text-sales">销量:{{ item.sales }}</view>
										</view>
									</view>
									<view>
										<image class="shop-add"
											src="https://hedashepin.oss-cn-guangzhou.aliyuncs.com/upload/3/20250402/09cf0a1a6c7c2efd061d325e7722f543.png"
											mode=""></image>
									</view>
								</view>
							</view>
						</view>
					</view>
					<!-- 加载更多提示 -->
					<view v-if="isLoading" class="loading-text">加载中...</view>
					<view v-if="!hasMore" class="no-more-text">没有更多了~</view>
				</view>
			</block>

			<uni-popup id="dialogHxqr" ref="dialogHxqr" type="dialog">
				<view class="hxqrbox">
					<image :src="hexiao_qr" @tap="previewImage" :data-url="hexiao_qr" class="img" />
					<view class="txt">请出示核销码给核销员进行核销</view>
					<view class="close" @tap="closeHxqr">
						<image src="/static/img/close2.png" style="width:100%;height:100%" />
					</view>
				</view>
			</uni-popup>

			<uni-popup id="dialogSelectExpress" ref="dialogSelectExpress" type="dialog">
				<view style="background:#fff;padding:20rpx 30rpx;border-radius:10rpx;width:600rpx"
					v-if="express_content">
					<view class="sendexpress" v-for="(item, index) in express_content" :key="index"
						style="border-bottom: 1px solid #f5f5f5;padding:20rpx 0;">
						<view class="sendexpress-item" @tap="goto"
							:data-url="'/pagesExt/order/logistics?express_com=' + item.express_com + '&express_no=' + item.express_no + '&id=' + orderinfo.id"
							style="display: flex;">
							<view class="flex1" style="color:#121212">{{ item.express_com }} - {{ item.express_no }}
							</view>
							<image src="/static/img/arrowright.png" style="width:30rpx;height:30rpx" />
						</view>
						<view v-if="item.express_oglist" style="margin-top:20rpx">
							<view class="oginfo-item" v-for="(item2, index2) in item.express_oglist" :key="index2"
								style="display: flex;align-items:center;margin-bottom:10rpx">
								<image :src="item2.pic"
									style="width:50rpx;height:50rpx;margin-right:10rpx;flex-shrink:0" />
								<view class="flex1" style="color:#555">{{ item2.name }}({{ item2.ggname }})</view>
							</view>
						</view>
					</view>
				</view>
			</uni-popup>
			<view v-if="selecthxnumDialogShow" class="popup__container">
				<view class="popup__overlay" @tap.stop="hideSelecthxnumDialog"></view>
				<view class="popup__modal">
					<view class="popup__title">
						<text class="popup__title-text">请选择核销数量</text>
						<image src="/static/img/close.png" class="popup__close" style="width:36rpx;height:36rpx"
							@tap.stop="hideSelecthxnumDialog" />
					</view>
					<view class="popup__content">
						<view class="pstime-item" v-for="(item, index) in hxnumlist" :key="index"
							@tap="hxnumRadioChange" :data-index="index">
							<view class="flex1">{{ item }}</view>
							<view class="radio" :style="hxnum == item ? 'background:' + t('color1') + ';border:0' : ''">
								<image class="radio-img" src="/static/img/checkd.png" />
							</view>
						</view>
					</view>
				</view>
			</view>

		</block>
		<loading v-if="loading"></loading>
		<dp-tabbar :opt="opt"></dp-tabbar>
		<popmsg ref="popmsg"></popmsg>
	</view>
</template>

<script>
	var app = getApp();

	export default {
		data() {
			return {
				opt: {},
				loading: false,
				isload: false,
				menuindex: -1,
				orderinfo: [],
				st: 'all',
				datalist: [],
				pagenum: 1,
				nomore: false,
				nodata: false,
				codtxt: "",
				canrefund: 1,
				express_content: '',
				selectExpressShow: false,
				hexiao_qr: '',
				keyword: '',
				showprice_dollar: false,
				is_product_glass: false,
				hexiao_qr: '',
				selecthxnumDialogShow: false,
				hxogid: '',
				hxnum: '',
				hxnumlist: [],
				sharetitle: '',
				sharepath: '',
				shareimageurl: '',
				shareData: {},
				likelist: [],
				page: 1,
				pageSize: 10,
				hasMore: true,
				isLoading: false,
				leftColumnList: [],
				rightColumnList: [],
			};
		},

		onLoad: function(opt) {

			this.opt = app.getopts(opt);
			if (this.opt && this.opt.st) {
				this.st = this.opt.st;
			}
			this.getdata();
			this.getlist();
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		onReachBottom: function() {
			if (!this.nodata && !this.nomore) {
				this.pagenum = this.pagenum + 1;
				this.getdata(true);
			}
			if (this.hasMore) {
				this.page++; // 页码+1
				this.getlist(); // 加载下一页
			}
		},
		onNavigationBarSearchInputConfirmed: function(e) {
			this.searchConfirm({
				detail: {
					value: e.text
				}
			});
		},
		computed: {
			showViewComment() {
				return this.datalist.every(product =>
					product.prolist && product.prolist.every(item => item.iscomment == 1)
				);
			}
		},
		methods: {
			gotoproid(i, type) {
				if (type == '' || type == 'shop') {
					app.goto('/pages/shop/product?id=' + i.proid + '&ptype=' + type)
				} else if (type == 'seckill') {
					app.goto('/pages/shop/product?id=' + i.procode + '&ptype=' + type)
				} else if (type == 'groupby') {
					app.goto('/pages/shop/product?id=' + i.procode + '&ptype=' + type)
				}
			},

			getOrderType(type, type2) {
				var t = ''
				switch (type) {
					case 'shop':
						t = '商城订单'
						if (type2 == 2) {
							t = '赠礼订单'
						}
						if (type2 == 3) {
							t = '收礼订单'
						}
						break;
					case 'seckill':
						t = '秒杀订单'
						break;
					case 'groupby':
						t = '团购订单'
						break;
					case 'scoreshop':
						t = '积分订单'
						break;
					default:
						t = '商城订单'
						break;
				}
				return t;
			},

			// btnShare(item) {
			// 	console.log(item.share);
			// 	const url = item.share.url
			// 	const title = item.share.title
			// 	const pic = item.share.pic
			// 	var that = this;
			// 	that.sharepath = item.share.url
			// 	that.sharetitle = item.share.title
			// 	that.shareimageurl = item.share.pic

			// 	uni.share({
			// 		title: title,
			// 		path: url,
			// 		imageUrl: pic,
			// 	});

			// },
			handleShare(item) {
				this.shareData = {
					title: item.share.title,
					path: item.share.url,
					imageUrl: item.share.pic
				}

				// 模拟点击分享按钮
				this.$nextTick(() => {
					if (this.$refs.shareButton) {
						this.$refs.shareButton.$el.click()
					}
				})
			},
			goDetail(item, i) {
				let id = item.id
				let ordernum = item.ordernum
				let aid = item.aid
				let gift_is_secret = item.gift_is_secret
				console.log(item);
				if (item.order_type == 2) {
					if (item.status == 0) {
						uni.navigateTo({
							url: './detail?id=' + id
						})
					} else {
						uni.navigateTo({
							url: './gift_datail?id=' + id + "&aid=" + aid + "&ordernum=" + ordernum +
								"&gift_is_secret=" + gift_is_secret
						})
					}
				} else {
					uni.navigateTo({
						url: './detail?id=' + id
					})
				}

			},
			getdata: function(loadmore) {
				if (!loadmore) {
					this.pagenum = 1;
					this.datalist = [];
				}
				var that = this;
				var pagenum = that.pagenum;
				var st = that.st;
				that.nodata = false;
				that.nomore = false;
				that.loading = true;
				app.showLoading("加载中");
				app.post('Order/orderlist', {
					st: st,
					pagenum: pagenum,
					keyword: that.keyword
				}, function(res) {
					app.showLoading(false);
					that.loading = false;
					var data = res.datalist;

					if (pagenum == 1) {
						that.codtxt = res.codtxt;
						that.canrefund = res.canrefund;
						that.showprice_dollar = res.showprice_dollar
						that.is_product_glass = res.is_product_glass
						that.datalist = data;
						if (data.length == 0) {
							that.nodata = true;
						}
						that.loaded();
					} else {
						if (data.length == 0) {
							that.nomore = true;
						} else {
							var datalist = that.datalist;
							var newdata = datalist.concat(data);
							that.datalist = newdata;
						}
					}
				});
			},
			getlist() {
				if (!this.hasMore || this.isLoading) return;
				this.isLoading = true;
				const that = this;

				app.get('Shop/guessLikeProduct', {
					page: this.page,
					pagelimit: this.pageSize
				}, function(res) {
					that.isLoading = false;

					if (res.status == 200) {
						const newData = res.data;
						if (that.page === 1) {
							if (newData.length >= 10) {
								that.likelist = newData;
							} else {
								that.likelist = [...that.likelist, ...newData];
								that.page = 2;
								that.getlist()
							}
						} else {
							that.likelist = [...that.likelist, ...newData];
						}

						// 拆分数据到左右两列（模拟瀑布流）
						that.splitDataToColumns();

						that.hasMore = newData.length >= that.pageSize;
						that.page++;
					} else {
						app.error(res.msg);
					}
				});
			},

			// 将数据拆分成左右两列（模拟瀑布流）
			splitDataToColumns() {
				this.leftColumnList = [];
				this.rightColumnList = [];

				this.likelist.forEach((item, index) => {
					if (index % 2 === 0) {
						this.leftColumnList.push(item);
					} else {
						this.rightColumnList.push(item);
					}
				});
			},
			changetab: function(st) {
				this.st = st;
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 0
				});
				this.getdata();
			},
			toclose: function(e) {
				var that = this;
				var orderid = e.currentTarget.dataset.id;
				app.confirm('确定要关闭该订单吗?', function() {
					app.showLoading('提交中');
					app.post('Order/closeOrder', {
						orderid: orderid
					}, function(data) {
						app.showLoading(false);
						app.success(data.msg);
						setTimeout(function() {
							that.getdata();
						}, 1000);
					});
				});
			},
			todel: function(e) {
				var that = this;
				var orderid = e.currentTarget.dataset.id;
				app.confirm('确定要删除该订单吗?', function() {
					app.showLoading('删除中');
					app.post('Order/delOrder', {
						orderid: orderid
					}, function(data) {
						app.showLoading(false);
						app.success(data.msg);
						setTimeout(function() {
							that.getdata();
						}, 1000);
					});
				});
			},
			orderCollect: function(e) {
				var that = this;
				var orderid = e.currentTarget.dataset.id;
				app.confirm('确定要收货吗?', function() {
					app.showLoading('提交中');
					app.post('Order/orderCollect', {
						orderid: orderid
					}, function(data) {
						app.showLoading(false);
						app.success(data.msg);
						setTimeout(function() {
							that.getdata();
						}, 1000);
					});
				});
			},
			logistics: function(e) {
				var index = e.currentTarget.dataset.index;
				var orderinfo = this.datalist[index];
				this.orderinfo = orderinfo;
				var express_com = orderinfo.express_com
				var express_no = orderinfo.express_no
				var express_content = orderinfo.express_content
				var express_type = orderinfo.express_type
				var prolist = orderinfo.prolist
				var from_order_type = orderinfo.from_order_type
				var id = orderinfo.id
				var from_order_id = orderinfo.from_order_id
				if (!express_content) {
					app.goto('/pagesExt/order/logistics?express_com=' + express_com + '&express_no=' + express_no +
						'&type=' +
						express_type + '&id=' + id + '&from_order_type=' + from_order_type +'&from_order_id=' + from_order_id);
				} else {
					express_content = JSON.parse(express_content);
					for (var i in express_content) {
						if (express_content[i].express_ogids) {
							var express_ogids = (express_content[i].express_ogids).split(',');
							console.log(express_ogids);
							var express_oglist = [];
							for (var j in prolist) {
								if (app.inArray(prolist[j].id + '', express_ogids)) {
									express_oglist.push(prolist[j]);
								}
							}
							express_content[i].express_oglist = express_oglist;
						}
					}
					this.express_content = express_content;
					console.log(express_content);
					this.$refs.dialogSelectExpress.open();
				}
			},
			hideSelectExpressDialog: function() {
				this.$refs.dialogSelectExpress.close();
			},
			showhxqr: function(e) {
				this.hexiao_qr = e.currentTarget.dataset.hexiao_qr
				this.$refs.dialogHxqr.open();
			},
			closeHxqr: function() {
				this.$refs.dialogHxqr.close();
			},
			searchConfirm: function(e) {
				this.keyword = e.detail.value;
				this.getdata(false);
			},
			showhxqr2: function(e) {
				var that = this;
				var leftnum = e.currentTarget.dataset.num - e.currentTarget.dataset.hxnum;
				this.hxogid = e.currentTarget.dataset.id;
				if (leftnum <= 0) {
					app.alert('没有剩余核销数量了');
					return;
				}
				var hxnumlist = [];
				for (var i = 0; i < leftnum; i++) {
					hxnumlist.push((i + 1) + '');
				}
				if (hxnumlist.length > 6) {
					that.hxnumlist = hxnumlist;
					that.selecthxnumDialogShow = true;
					that.hxnum = '';
				} else {
					uni.showActionSheet({
						itemList: hxnumlist,
						success: function(res) {
							if (res.tapIndex >= 0) {
								that.hxnum = hxnumlist[res.tapIndex];
								that.gethxqr();
							}
						}
					});
				}
			},
			gethxqr() {
				var that = this;
				var hxnum = this.hxnum;
				var hxogid = this.hxogid;
				if (!hxogid) {
					app.alert('请选择要核销的商品');
					return;
				}
				if (!hxnum) {
					app.alert('请选择核销数量');
					return;
				}
				app.showLoading();
				app.post('Order/getproducthxqr', {
					hxogid: hxogid,
					hxnum: hxnum
				}, function(data) {
					app.showLoading(false);
					if (data.status == 0) {
						app.alert(data.msg);
					} else {
						that.hexiao_qr = data.hexiao_qr
						that.$refs.dialogHxqr.open();
					}
				});
			},
			hxnumRadioChange: function(e) {
				var that = this;
				var index = e.currentTarget.dataset.index;
				this.hxnum = this.hxnumlist[index];
				setTimeout(function() {
					that.selecthxnumDialogShow = false;
					that.gethxqr();
				}, 200)
			},
			hideSelecthxnumDialog: function() {
				this.selecthxnumDialogShow = false;
			},
			checkRT(data) {
				//待付款0  待发货1 待提货2 待收货3 已完成4 已关闭5
				if (data.status == 0) {
					return 0
				}
				if (data.status == 1 && data.freight_type != 1) {
					return 1
				}
				if (data.status == 1 && data.freight_type == 1) {
					return 2
				}
				if (data.status == 2) {
					return 3
				}
				if (data.status == 3) {
					return 4
				}
				if (data.status == 4) {
					return 5
				}
			}
		},
		onShareAppMessage(res) {
			if (res.from === 'button') {
				return this.shareData
			}
		},
	};
</script>
<style>
	.container {
		width: 100%;
	}

	.topsearch {
		width: 94%;
		margin: 10rpx 3%;
	}

	.topsearch .f1 {
		height: 60rpx;
		border-radius: 30rpx;
		border: 0;
		background-color: #fff;
		flex: 1
	}

	.topsearch .f1 .img {
		width: 24rpx;
		height: 24rpx;
		margin-left: 10px
	}

	.topsearch .f1 input {
		height: 100%;
		flex: 1;
		padding: 0 20rpx;
		font-size: 28rpx;
		color: #333;
	}

	.order-content {
		display: flex;
		flex-direction: column
	}

	.order-box {
		width: 94%;
		margin: 10rpx 3%;
		padding: 6rpx 3%;
		background: #fff;
		border-radius: 8px
	}

	.order-box .head {
		display: flex;
		width: 100%;
		border-bottom: 1px #f4f4f4 solid;
		height: 70rpx;
		line-height: 70rpx;
		overflow: hidden;
		color: #999;
	}

	.order-box .head .f1 {
		display: flex;
		align-items: center;
		color: #333
	}

	.order-box .head image {
		width: 34rpx;
		height: 34rpx;
		margin-right: 4px
	}

	.order-box .head .st0 {
		width: 140rpx;
		color: #ff8758;
		text-align: right;
	}

	.order-box .head .st1 {
		width: 140rpx;
		color: #ffc702;
		text-align: right;
	}

	.order-box .head .st2 {
		width: 140rpx;
		color: #ff4246;
		text-align: right;
	}

	.order-box .head .st3 {
		width: 140rpx;
		color: #999;
		text-align: right;
	}

	.order-box .head .st4 {
		width: 140rpx;
		color: #bbb;
		text-align: right;
	}

	.order-box .content {
		display: flex;
		width: 100%;
		padding: 16rpx 0px;
		border-bottom: 1px #f4f4f4 dashed;
		position: relative;
		align-items: center;
	}

	.order-box .content:last-child {
		border-bottom: 0;
	}

	.order-box .content image {
		width: 140rpx;
		height: 140rpx;
	}

	.order-box .content .detail {
		display: flex;
		flex-direction: column;
		margin-left: 14rpx;
		flex: 1
	}

	.order-box .content .detail .t1 {
		font-size: 26rpx;
		line-height: 36rpx;
		margin-bottom: 10rpx;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
		overflow: hidden;
	}

	.order-box .content .detail .t2 {
		height: 44rpx;
		line-height: 44rpx;
		color: #999;
		overflow: hidden;
		font-size: 24rpx;
	}

	.order-box .content .detail .t3 {
		display: flex;
		height: 40rpx;
		line-height: 40rpx;
		color: #ff4246;
	}

	.order-box .content .detail .x1 {
		flex: 1
	}

	.order-box .content .detail .x2 {
		width: 100rpx;
		font-size: 32rpx;
		text-align: right;
		margin-right: 8rpx
	}

	.order-box .bottom {
		width: 100%;
		padding: 10rpx 0px;
		border-top: 1px #f4f4f4 solid;
		color: #555;
	}


	.order-box .bottom2 {
		width: 100%;
		padding: 10rpx 0px;
		border-top: 1px #f4f4f4 solid;
		color: #555;
		display: flex;
	}

	.ordertype {
		/* position: absolute; */
		font-weight: bold;
		margin-right: 20rpx;
		text-wrap: nowrap;
	}


	.order-box .op {
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-end;
		align-items: center;
		width: 100%;
		padding: 10rpx 0px;
		border-top: 1px #f4f4f4 solid;
		color: #555;
	}

	.btn1 {
		margin-left: 20rpx;
		margin-top: 10rpx;
		max-width: 160rpx;
		height: 60rpx;
		line-height: 60rpx;
		color: #fff;
		border-radius: 3px;
		text-align: center;
		padding: 0 20rpx;
	}

	.btn2 {
		margin-left: 20rpx;
		margin-top: 10rpx;
		max-width: 160rpx;
		height: 60rpx;
		line-height: 60rpx;
		color: #333;
		background: #fff;
		border: 1px solid #cdcdcd;
		border-radius: 3px;
		text-align: center;
		padding: 0 20rpx;
	}

	.hxqrbox {
		background: #fff;
		padding: 50rpx;
		position: relative;
		border-radius: 20rpx
	}

	.hxqrbox .img {
		width: 400rpx;
		height: 400rpx
	}

	.hxqrbox .txt {
		color: #666;
		margin-top: 20rpx;
		font-size: 26rpx;
		text-align: center
	}

	.hxqrbox .close {
		width: 50rpx;
		height: 50rpx;
		position: absolute;
		bottom: -100rpx;
		left: 50%;
		margin-left: -25rpx;
		border: 1px solid rgba(255, 255, 255, 0.5);
		border-radius: 50%;
		padding: 8rpx
	}

	.tgr {
		font-size: 24rpx;
	}

	.pstime-item {
		display: flex;
		border-bottom: 1px solid #f5f5f5;
		padding: 20rpx 30rpx;
	}

	.pstime-item .radio {
		flex-shrink: 0;
		width: 32rpx;
		height: 32rpx;
		background: #FFFFFF;
		border: 2rpx solid #BFBFBF;
		border-radius: 50%;
		margin-right: 30rpx
	}

	.pstime-item .radio .radio-img {
		width: 100%;
		height: 100%
	}

	.pdl10 {
		padding-left: 10rpx;
	}

	.gift-box {
		display: flex;
		justify-content: space-between;
	}

	.gift-left {
		display: flex;
		align-items: center;
	}

	.gift-left-img {
		width: 30rpx;
		height: 30rpx;
		margin-right: 10rpx;
	}

	.img-icon {
		width: 100%;
		height: 100%;
	}

	.btn-share {
		height: 62rpx;
		line-height: 60rpx;
		font-size: 28rpx;
		color: #333;
	}

	.tips-box {
		display: flex;
		align-items: center;
		background-color: #f4f4f4;
		justify-content: space-between;
		padding: 20rpx;

	}

	.tips-box-left {
		color: #888;
		font-size: 26rpx;
	}

	.tips-text {}

	.tips-time {
		margin-top: 20rpx;
	}

	.tips-box-right {
		margin-left: 20rpx;
	}

	.arrow-right {
		width: 30rpx;
		height: 30rpx;
	}

	.waterfall-container {
		width: 100%;
		height: 100vh;
		/* 可根据需要调整高度 */
		padding: 10rpx;
		box-sizing: border-box;
	}

	.waterfall-list {
		display: flex;
		justify-content: space-between;
		padding: 0 10rpx;
	}

	.like {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 20rpx 0;
	}

	.like-icon {
		width: 30rpx;
		height: 30rpx;
		margin-right: 10rpx;
	}

	.waterfall-column {
		width: 48%;
		/* 两列布局，留一点间距 */
	}

	.waterfall-column .item {
		margin-bottom: 20rpx;
		background: #fff;
		border-radius: 12rpx;
		overflow: hidden;
		/* box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); */
	}

	.shop-image {
		width: 100%;
		display: block;
	}

	.shop-text {
		padding: 16rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.shop-text-name {
		font-size: 28rpx;
		color: #333;
		margin-bottom: 10rpx;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}


	.shop-text-price {
		font-size: 32rpx;
		color: #ff4d4f;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.shop-text-sales {
		font-size: 24rpx;
		color: #999;
	}

	.shop-add {
		width: 48rpx;
		height: 48rpx;
	}

	.loading-text,
	.no-more-text {
		text-align: center;
		padding: 20rpx;
		color: #999;
		font-size: 26rpx;
	}
</style>